﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns
{
    /// <summary>
    /// 物流公司发货基类
    /// 运输方式、包装样式、运输类型
    /// </summary>
    public class Matter
    {
        /// <summary>
        /// 包装样式
        /// </summary>
        public string PackStyle { get; set; }
        /// <summary>
        /// 运输方式
        /// </summary>
        public string TransportWay { get; set; }
        /// <summary>
        /// 是否有税费
        /// </summary>
        public string IsHaveTax { get; set; }
        /// <summary>
        /// 总金额
        /// </summary>
        /// <returns></returns>
        public double Money { get; set; }
        /// <summary>
        /// 描述信息
        /// </summary>
        public string DescriptionInfo { get; set; }
    }

    /// <summary>
    /// 发货实现类 :抽象建造者
    /// </summary>
    public abstract class SendModelBuilder
    {
        protected Matter matter = new Matter();

        public abstract void BuilderPackStyle();

        public abstract void BuilderTransportWay();

        public abstract void BuilderIsHaveTax();

        public abstract void BuilderMoney();

        public abstract void BuilderDescriptionInfo();

        /// <summary>
        /// 返回一个完整得发货实现类
        /// </summary>
        /// <returns></returns>
        public Matter CreateMatter()
        {
            return matter;
        }
    }


    /// <summary>
    /// 日本地区创建者
    /// </summary>
    public class RiBenBuilder : SendModelBuilder
    {
        public override void BuilderPackStyle()
        {
            matter.PackStyle = "木质箱子包装";
        }

        public override void BuilderTransportWay()
        {
            matter.TransportWay = "水路";
        }

        public override void BuilderIsHaveTax()
        {
            matter.IsHaveTax = "有";
        }

        public override void BuilderMoney()
        {
            matter.Money = 1000;
        }

        public override void BuilderDescriptionInfo()
        {
            matter.DescriptionInfo = "此次运输为水路运输，货物为木质箱子包装，有税费，金额为1000元";
        }
    }

    /// <summary>
    /// 北京地区创建者
    /// </summary>
    public class BeiJingBuilder : SendModelBuilder
    {
        public override void BuilderPackStyle()
        {
            matter.PackStyle = "纸盒";
        }

        public override void BuilderTransportWay()
        {
            matter.TransportWay = "陆运";
        }

        public override void BuilderIsHaveTax()
        {
            matter.IsHaveTax = "有";
        }

        public override void BuilderMoney()
        {
            matter.Money = 50;
        }

        public override void BuilderDescriptionInfo()
        {
            matter.DescriptionInfo = "此次运输为陆运运输，货物为纸盒包装，无税费，金额为50元";
        }
    }

    public class BuilderPattern
    {
        public Matter SendModel(SendModelBuilder builder)
        {
            builder.BuilderPackStyle();
            builder.BuilderTransportWay();
            builder.BuilderIsHaveTax();
            builder.BuilderMoney();
            builder.BuilderDescriptionInfo();
            return builder.CreateMatter();
        }
    }
}
